<?php
ob_start();
ignore_user_abort(true);
date_default_timezone_set("Asia/Shanghai");
if(isset($_SERVER['HTTP_APPVERSION'])){
include "./saesiteinfo.php";
}else{
 if(!file_exists("./install/install.lock")){
header('location:./install');
exit;
 }else{
include "./siteinfo.php";
 }
}
include "./function.php";
//连接数据库
$localhost=mysql_connect($sqlhost,$sqluser,$sqlpass)or die("无法连接服务器");
mysql_select_db($sqldata,$localhost);
if (isset($_COOKIE["SHANIUUSER"]) && isset($_COOKIE["SHANIUPASS"])){
$user=$_COOKIE["SHANIUUSER"];
$pass=$_COOKIE["SHANIUPASS"];
//获取用户资料
$mysql = mysql_query("SELECT * FROM user WHERE user='$user'");
$sql= mysql_fetch_array($mysql);
//获取QQ数
$qqnumsql="SELECT COUNT(id) FROM qqlist WHERE myqq='$user' ";
$qqnumqqlist = mysql_fetch_array( mysql_query($qqnumsql) );
$qqnum=$qqnumqqlist[0];
//随机获取服务器
$suiji[1]="fw1";
$suiji[2]="fw2";
$suiji[3]="fw3";
$suiji[4]="fw4";
$suiji[5]="fw5";
$suiji[6]="fw6";
$suiji[7]="fw7";
$suiji[8]="fw8";
$suijishu=rand(1,8);
$fuwu=$suiji[$suijishu];
//获取当前时间
$time=time();
//QID生成
$qid=date("Ymd")."".rand(1000000000,9999999999)."".date("His");
//初始化挂Q
$qq=$_POST['qq'];
$pw=$_POST['pw'];
$qqlistrow = mysql_query("SELECT * FROM qqlist WHERE qq='$qq' and myqq='$user'");
$qqlist=mysql_fetch_array($qqlistrow);
$ssqq=mysql_query("select * from qqlist where qq='$qq'"); 
$ssqqnum=mysql_num_rows($ssqq);
if($ssqqnum)
 {  
echo "亲QQ是不是已经增加过了啊！！"  ;
 }
 else{
if(isset($_pass['pass'])){
echo "您还没有登录";
}else{
//挂Q判断开始
if ($qq==""){
echo "QQ帐号不能为空";
}elseif($pw==""){
echo "QQ密码不能为空";
}elseif (isset($_POST['yzm'])){
$out=addqqyyzm($_POST['qq'],$_POST['pw'],$_POST['r'],$_POST['extend'],$_POST['r_sid'],$_POST['sid'],$_POST['ip'],$_POST['hidpw'],$_POST['verify']);
}else{
$out=addqqwyzm($qq,$pw);
}
//@@@@@@@@@@@@@@@@@@
if($qqnum>=$sql['peie']+$chushi){
echo "系统提示:挂Q配额已满,请扩充";
}elseif (@eregi("您输入的账号不存在",$out)){
echo "系统提示:您输入的账号不存在";
}elseif(@eregi("操作异常",$out)){
$a=explode('请输入上图字符(不区分大小写)：',$out);
$outt=$a[0];
$b=$a[1];
$img=explode('src="',$outt);
$img=explode('" alt="',$img[1]);
$rt=explode('name="r" value="',$out);
$rw=explode('"/>',$rt[1]);
$extendt=explode('name="extend" value="',$out);
$extendw=explode('"/>',$extendt[1]);
$r_sidt=explode('name="r_sid" value="',$out);
$r_sidw=explode('"/>',$r_sidt[1]);
$login_urlt=explode('name="login_url" value="',$out);
$login_urlw=explode('"/>',$login_urlt[1]);
$sidt=explode('name="sid" value="',$out);
$sidw=explode('"/>',$sidt[1]);
$ipt=explode('name="rip" value="',$out);
$ipw=explode('"/>',$ipt[1]);
$hidpwt=explode('name="hexpwd" value="',$out);
$hidpww=explode('"/>',$hidpwt[1]);
echo '遇到QQ验证码:<br /><img src="'.$img[0].'">';
echo '<form name="aa" action="" method="post">';
echo '<input type="hidden" name="qq" value="'.$qq.'"/>';
echo '<input type="hidden" name="pw" value="'.$pw.'"/>';
echo '<input type="hidden" name="r" value="'.$rw[0].'"/>';
echo '<input type="hidden" name="extend" value="'.$extendw[0].'"/>';
echo '<input type="hidden" name="r_sid" value="'.$r_sidw[0].'"/>';
echo '<input type="hidden" name="login_url" value="'.$login_urlw[0].'"/>';
echo '<input type="hidden" name="sid" value="'.$sidw[0].'"/>';
echo '<input type="hidden" name="ip" value="'.$ipw[0].'">';
echo '<input type="hidden" name="hidpw" value="'.$hidpww[0].'">';
echo '<input type="text" name="verify" value="" style="width:100px">';
echo '<br />';
echo '<input type="submit" name="yzm" value="马上登录" style="width:100px">';
echo '</form>';
}elseif(@eregi("密码不正确",$out)){
echo '您的QQ帐号或密码不正确';
}elseif(@eregi("系统繁忙",$out)){
echo '系统繁忙为您获取SID码';
}elseif(@eregi("登录3GQQ成功",$out)){
$out=explode('sid=',$out);
$sid=substr($out[1],0,24);
$qqpassword = tesy_encrypt($pw);
mysql_query("INSERT INTO qqlist (myqq,fwq,qid,qq,pw,sid,time) VALUES ('$user','$fuwu','$qid','$qq','$qqpassword','$sid','$time')");
mysql_query("INSERT INTO $fuwu (qid,qq,pw,sid) VALUES ('$qid','$qq','$qqpassword','$sid')");
//呼出提示
echo "挂Q记录添加成功,请刷新页面";
file_get_contents("http://ti.3g.qq.com/g/s?sid=" . $sid . "&r=" . $qq. "&aid=arelate&ac=42&tu=weibiantai&bid=h%23QQGenius%230%230%230%2316");
//开启在线状态
file_get_contents('http://q32.3g.qq.com/g/s?sid='.$sid.'&s=10&aid=chgStatus');
}else{
echo "<br />系统提示:发生错误";
}
//@@@@@@@@@@@@@@@@@@
}

}}else{
//如果没登录就显示下面的
header("Location: ./tishi.php");
}
?>